# -*- coding: utf-8 -*-

# 计算武汉市植被指数年度平均栅格数据

# input 年度逐月栅格数据表，dbf格式
# output 年平均栅格数据表， dbf格式


import os
import dbfread
import xlwt


def filter(folder):
    fs = os.listdir(folder)
    for i in fs:
        if i.endswith(".dbf"):
            yield os.path.join(folder, i)



def calc(dbf_dir):
    for i in filter(dbf_dir):
        table = dbfread.DBF(i, load=True)
        count = 0
        for j in table:
            # print(j["Value"])
            count += 1
        print(count)
        # break



if __name__ == "__main__":
    test_dir = r"E:\毕设数据\Example\WuhanNDVI\2020"
    calc(test_dir)